package com.study.行为型模式.命令模式;

public class Client {

    public static void main(String[] args) {

        //使用命令设计模式，完成通过遥控器，对电灯读操作
        //创建电灯对象
        LightReceiver lightReceiver = new LightReceiver();
        //创建电灯相关的开关命令
        LightOnCommand lightOnCommand = new LightOnCommand(lightReceiver);
        LightOffCommand lightOffCommand = new LightOffCommand(lightReceiver);

        //创建一个遥控器
        RemoteController remoteController = new RemoteController();
        //给遥控器安装按钮
        //第一排是电灯的开关按钮
        remoteController.setCommand(0,lightOnCommand,lightOffCommand);

        //开启电灯
        System.out.println("-----按下开灯按钮-----");
        remoteController.onButtonWasPushed(0);
        System.out.println("-----按下关灯按钮-----");
        remoteController.offButtonWasPushed(0);
        System.out.println("按下撤销按钮");
        remoteController.undoButtonWasPushed();
    }
}
